package com.zsj.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @Description:
 * @Author:duoaipan
 * @Date Created in 14:56 2019-04-19
 */
public class RegexValidateUtil {


    /**
     * 通用正则校验
     * @param regex
     * @param validateParam
     * @return
     */
    public static boolean validate(String regex, String validateParam) {
        Matcher m = Pattern.compile(regex).matcher(validateParam);
        return m.matches();
    }

    public static boolean verifyPartialMatch(String regex, String validateParam) {
        Matcher m = Pattern.compile(regex).matcher(validateParam);
        return m.find();
    }

    public static void main(String[] args) {

        System.out.println(RegexValidateUtil.validate("^(86)?1((((33)|(53)|(8[019])|(7[37])|(9[139]))\\d{8}))$",
                "13508333333"));

    }

}
